package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.comment.VolumeComment;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BEAnjuan;
import com.ruoyi.system.service.IBEAnjuanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 案卷管理Controller
 * 
 * @author ruoyi
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/anjuan")
public class BEAnjuanController extends BaseController
{
    @Autowired
    private IBEAnjuanService bEAnjuanService;

    /**
     * 查询案卷管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:anjuan:list')")
    @GetMapping("/list")
    public TableDataInfo list(BEAnjuan bEAnjuan)
    {
        startPage();
        List<BEAnjuan> list = bEAnjuanService.selectBEAnjuanList(bEAnjuan);
        return getDataTable(list);
    }

    /**
     * 导出案卷管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:anjuan:export')")
    @Log(title = "案卷管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BEAnjuan bEAnjuan)
    {
        List<BEAnjuan> list = bEAnjuanService.selectBEAnjuanList(bEAnjuan);
        ExcelUtil<BEAnjuan> util = new ExcelUtil<BEAnjuan>(BEAnjuan.class);
        util.exportExcel(response, list, "案卷管理数据");
    }

    /**
     * 获取案卷管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:anjuan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(bEAnjuanService.selectBEAnjuanById(id));
    }

    /**
     * 新增案卷管理
     */
//    @PreAuthorize("@ss.hasPermi('system:anjuan:add')")
    @Log(title = "案卷管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BEAnjuan bEAnjuan)
    {
        return toAjax(bEAnjuanService.insertBEAnjuan(bEAnjuan));
    }

    /**
     * 修改案卷管理
     */
//    @PreAuthorize("@ss.hasPermi('system:anjuan:edit')")
    @Log(title = "案卷管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BEAnjuan bEAnjuan)
    {
        return toAjax(bEAnjuanService.updateBEAnjuan(bEAnjuan));
    }

    /**
     * 删除案卷管理
     */
//    @PreAuthorize("@ss.hasPermi('system:anjuan:remove')")
    @Log(title = "案卷管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bEAnjuanService.deleteBEAnjuanByIds(ids));
    }


    /**
     * 查询案卷注释信息列表
     *
     * @return 案卷信息集合
     */
    @PostMapping("/getAnjuanCommentInfo")
    public List<VolumeComment> getAnjuanCommentInfo() {
        return bEAnjuanService.selectBEAnjuanComInfoList();
    }
}
